function [uwbdata] = uwbread(serialOpened,anchorNum,maxlength)

if nargin <=2
    maxlength  = 1000;
end
if nargin ==1
    anchorNum  = 3;
end

distances =zeros(anchorNum,measurementLength);
indicesSet = 1:anchorNum;
while(true)
    str  = fscanf(serialuwbagent,'%s');
    a    = sscanf(str,'distance%d:%dmm,');
    if length(a)==2
        assert(a(1)<=anchorNum);
        measurementIndeices(a(1)) = measurementIndeices(a(1))+1;
        if(measurementIndeices(a(1))>measurementLength)
            save(strcat(fileprefix,'_',num2str(round(now*1e6)),'.mat'));
            break;
        else
            distances(a(1),measurementIndeices(a(1)))= a(2);
        end
    end
end